package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AdminPrizeConfig;
import com.ruoyi.system.service.IAdminPrizeConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 开奖设置Controller
 * 
 * @author ruoyi
 * @date 2020-09-22
 */
@RestController
@RequestMapping("/system/prizeConfig")
public class AdminPrizeConfigController extends BaseController
{
    @Autowired
    private IAdminPrizeConfigService adminPrizeConfigService;

    /**
     * 查询开奖设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:prizeConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdminPrizeConfig adminPrizeConfig)
    {
        startPage();
        List<AdminPrizeConfig> list = adminPrizeConfigService.selectAdminPrizeConfigList(adminPrizeConfig);
        return getDataTable(list);
    }

    /**
     * 导出开奖设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:prizeConfig:export')")
    @Log(title = "开奖设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdminPrizeConfig adminPrizeConfig)
    {
        List<AdminPrizeConfig> list = adminPrizeConfigService.selectAdminPrizeConfigList(adminPrizeConfig);
        ExcelUtil<AdminPrizeConfig> util = new ExcelUtil<AdminPrizeConfig>(AdminPrizeConfig.class);
        return util.exportExcel(list, "prizeConfig");
    }

    /**
     * 获取开奖设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:prizeConfig:query')")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Long configId)
    {
        return AjaxResult.success(adminPrizeConfigService.selectAdminPrizeConfigById(configId));
    }

    /**
     * 新增开奖设置
     */
    @PreAuthorize("@ss.hasPermi('system:prizeConfig:add')")
    @Log(title = "开奖设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdminPrizeConfig adminPrizeConfig)
    {
        return toAjax(adminPrizeConfigService.insertAdminPrizeConfig(adminPrizeConfig));
    }

    /**
     * 修改开奖设置
     */
    @PreAuthorize("@ss.hasPermi('system:prizeConfig:edit')")
    @Log(title = "开奖设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdminPrizeConfig adminPrizeConfig)
    {
        return toAjax(adminPrizeConfigService.updateAdminPrizeConfig(adminPrizeConfig));
    }

    /**
     * 删除开奖设置
     */
    @PreAuthorize("@ss.hasPermi('system:prizeConfig:remove')")
    @Log(title = "开奖设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Long[] configIds)
    {
        return toAjax(adminPrizeConfigService.deleteAdminPrizeConfigByIds(configIds));
    }
}
